package com.erp.ae.controller;

import com.erp.ae.domain.bo.AeMsgSaveBo;
import com.erp.ae.domain.vo.AeMsgSaveVo;
import com.erp.ae.service.IAeMsgSaveService;
import com.ruoyi.common.core.annotation.RepeatSubmit;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.web.oldController.BaseController;
import com.ruoyi.common.core.web.oldPage.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * ae消息推送信息保存
 *
 * @author erp
 * @date 2023-05-17
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/msgSave")
public class AeMsgSaveController extends BaseController {

    @Resource
    IAeMsgSaveService iAeMsgSaveService;

    /**
     * 查询ae消息推送信息保存列表
     */
    @GetMapping("/list")
    public TableDataInfo<AeMsgSaveVo> list(AeMsgSaveBo bo, PageQuery pageQuery) {
        return iAeMsgSaveService.queryPageList(bo, pageQuery);
    }


    /**
     * 获取ae消息推送信息保存详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<AeMsgSaveVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(iAeMsgSaveService.queryById(id));
    }

    /**
     * 新增ae消息推送信息保存
     */
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody AeMsgSaveBo bo) {
        return toAjax(iAeMsgSaveService.insertByBo(bo));
    }

    /**
     * 修改ae消息推送信息保存
     */
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody AeMsgSaveBo bo) {
        return toAjax(iAeMsgSaveService.updateByBo(bo));
    }

    /**
     * 删除ae消息推送信息保存
     *
     * @param ids 主键串
     */
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iAeMsgSaveService.deleteWithValidByIds(Arrays.asList(ids), true));
    }


//    public R<Object> receiveGopCallback() {
//        return  iAeMsgSaveService.receiveGopCallback();
//    }
}
